﻿<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    assembly="JSC.Portal.Core" namespace="JSC.Portal.Entities">

	<class name="PortalSite" table="jsc_site" lazy="false">

		<!-- start Base on every entity -->
		<id name="Id" column="siteid" unsaved-value="-1">
			<generator class="native">
				<param name="sequence">jsc_site_siteid_seq</param>
			</generator>
		</id>

		<property name="Name" column="name" not-null="true"/>
		<property name="Description" column="description"/>
		<!-- end Base on every entity -->

    <property name="Url" column="url"/>
		<property name="DefaultLanguage" column="defaultlanguage"/>
    <property name="WebmasterMail" column="webmastermail"/>
    <property name="ValidFrom" column="validfrom"/>
		<property name="ValidTill" column="validtill"/>
    <property name="MetaKeywords" column="metakeywords"/>
    <property name="MetaDescription" column="metadescription"/>
    <property name="CreatedOn" column="createdtimestamp" type="DateTime"/>
    <property name="ModifiedOn" column="modifiedtimestamp" type="DateTime"/>
    <many-to-one name="CreatedByUser" class="PortalUser" column="createdby" not-null="false" not-found="ignore"/>
    <many-to-one name="ModifiedByUser" class="PortalUser" column="modifiedby" not-null="false" not-found="ignore"/>
    <many-to-one name="DefaultTemplate" class="Template" column="defaulttemplateid" not-null="false" not-found="ignore"/>

    <bag name="PortalPages"
         table="jsc_page"
         inverse="true"
         lazy="true"
         order-by="position asc"
         cascade="all">
      <key column="siteid" />
      <one-to-many class="PortalPage"
                   not-found="ignore" />
    </bag>
    
    <bag name="LicensedModules"
         table="jsc_sitelicense"
         lazy="true"
         cascade="all">
      <key column="siteid" />
      <composite-element class="SiteLicense">
        <parent name="PortalSite" />
        <property name="Licensed" column="licensed" type="Boolean" />
        <many-to-one name="LicensedModule" class="ModuleType" column="moduletypeid" cascade="none" />
      </composite-element>
    </bag>
  </class>
</hibernate-mapping>